package com.powernode.commons;


import lombok.Data;
import lombok.ToString;

@ToString
@Data
public class Result {
    //不是描述请求状态，描述当前业务操作后的结果状态
    private Integer code;

    private String message;//success failure   登录失败   超时

    private Object data;

    public Result(Integer code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public Result(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Result() {
    }

    /**
     * 成功
     */
    public static Result OK(){
        return new Result(200,"success");
    }

    public static Result OK(Object data){
        return new Result(200,"success",data);
    }


    public static Result build(ResultException exception){
        return new Result(exception.getCode(),exception.getMessage());
    }

}
